﻿using System;
using RootMotion.FinalIK;
using Studio;
using UnityEngine;

namespace WzhAddon
{
	public class AdvancedIKControlNode : MonoBehaviour
	{
		public AdvancedIKController controller;
		public GuideObject guideObject;
		public IKEffector effectorTarget;
		public FBIKChain bendGoal;
		public Transform target;
		private OCIChar.IKInfo ikInfo;
		public string label;
		public float weight;
		public float rotationWeight;
		public void Init(OCIChar.IKInfo ikInfo, GuideObject guideObject, IKEffector target, string label)
		{
			this.ikInfo = ikInfo;
			this.guideObject = guideObject;
			this.effectorTarget = target;
			this.target = this.effectorTarget.target;
			this.weight = 1f;
			this.rotationWeight = 1f;
			this.label = label;
			this.InstallSelectionHandler();
		}

		public void Init(OCIChar.IKInfo ikInfo, GuideObject guideObject, FBIKChain bendGoal, string label)
		{
			this.ikInfo = ikInfo;
			this.guideObject = guideObject;
			this.bendGoal = bendGoal;
			this.target = bendGoal.bendConstraint.bendGoal;
			this.weight = 1f;
			this.label = label;
			this.InstallSelectionHandler();
		}

		private void InstallSelectionHandler()
		{
			if (this.guideObject == null) return;
			this.guideObject.guideSelect.gameObject.AddComponent<IKNodeSelectionHandler>().node = this;
		}
		private void OnMouseDown()
		{
			//BaseMgr<AdvancedIKMgr>.Instance.gui.SetFocusNode(this);
		}
		private class IKNodeSelectionHandler : MonoBehaviour
		{
			public AdvancedIKControlNode node;
			private void OnMouseDown()
			{
				//BaseMgr<AdvancedIKMgr>.Instance.gui.SetFocusNode(this.node);
			}
		}
	}
}
